package com.collect.zambia.zhiAdater.zhiFilterDaily;

import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.collect.zambia.R;
import com.collect.zambia.zhiAdater.zhiFilterPerformance.OnZHIFilterAdjusterItemClickListener;
import com.collect.zambia.zhiBean.zhiReceive.ZHIRFilterEntity;

public class ZHIFilterConditionAdjuster extends BaseQuickAdapter<ZHIRFilterEntity, BaseViewHolder> {

    public ZHIFilterConditionAdjuster() {
        super(R.layout.item_filter_condition_list, null);
    }

    private OnZHIFilterAdjusterItemClickListener mOnZHIFilterAdjusterItemClickListener;

    @Override
    protected void convert(BaseViewHolder helper, ZHIRFilterEntity item) {
        TextView tv_level = helper.getView(R.id.tv_title);
        tv_level.setText(item.getLevel());

        tv_level.setBackgroundResource(item.isChecked() ? R.drawable.bg_solid_radius_theme_blue0_16dp : R.drawable.bg_solid_radius_theme_black4_16dp);
        tv_level.setTextColor(item.isChecked() ? mContext.getResources().getColor(R.color.white) : mContext.getResources().getColor(R.color.theme_transparent_4));

        helper.getView(R.id.tv_title).setOnClickListener(v -> {
            if (mOnZHIFilterAdjusterItemClickListener != null) {
                mOnZHIFilterAdjusterItemClickListener.OnItemClick(item, helper.getAdapterPosition());
            }
        });
    }

    public void setOnZHIFilterAdjusterItemClickListener(OnZHIFilterAdjusterItemClickListener listener) {
        this.mOnZHIFilterAdjusterItemClickListener = listener;
    }
}
